check button: Deprecate and ignore ::indicator-spacing
authorMatthias Clasen <mclasen@redhat.com>
Wed, 16 Dec 2015 17:27:53 +0000 (12:27 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 16 Dec 2015 17:27:53 +0000 (12:27 -0500)
This can be done just as well with CSS margins, so
do that instead for Adwaita.

gtk/gtkcheckbutton.c
gtk/theme/Adwaita/_common.scss
gtk/theme/Adwaita/gtk-contained-dark.css
gtk/theme/Adwaita/gtk-contained.css

index 471543aa594e6d63ed1c39465824704354de6489..4d875e33b963b92332c150d5f418fbc2df2f2461 100644 (file)
@@ -223,6 +223,15 @@ gtk_check_button_class_init (GtkCheckButtonClass *class)
                                                             G_MAXINT,
                                                             INDICATOR_SIZE,
                                                             GTK_PARAM_READABLE));
+
+  /**
+   * GtkCheckButton:indicator-spacing:
+   *
+   * The spacing around the indicator.
+   *
+   * Deprecated: 3.20: Use CSS margins of the indicator node,
+   *    the value of this style property is ignored.
+   */
   gtk_widget_class_install_style_property (widget_class,
                                           g_param_spec_int ("indicator-spacing",
                                                             P_("Indicator Spacing"),
@@ -230,7 +239,7 @@ gtk_check_button_class_init (GtkCheckButtonClass *class)
                                                             0,
                                                             G_MAXINT,
                                                             INDICATOR_SPACING,
-                                                            GTK_PARAM_READABLE));
+                                                            GTK_PARAM_READABLE|G_PARAM_DEPRECATED));
 
   gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_CHECK_BOX);
   gtk_widget_class_set_css_name (widget_class, "checkbutton");
@@ -441,19 +450,14 @@ gtk_check_button_measure (GtkCssGadget   *gadget,
       if (child && gtk_widget_get_visible (child))
         {
           gint child_min, child_nat;
-          gint spacing;
-
-          gtk_widget_style_get (widget,
-                                "indicator-spacing", &spacing,
-                                NULL);
 
           _gtk_widget_get_preferred_size_for_size (child,
                                                    GTK_ORIENTATION_HORIZONTAL,
                                                    for_size,
                                                    &child_min, &child_nat,
                                                    NULL, NULL);
-          *minimum = check_min + 2 * spacing + child_min;
-          *natural = check_nat + 2 * spacing + child_nat;
+          *minimum = check_min + child_min;
+          *natural = check_nat + child_nat;
         }
       else
         {
@@ -680,7 +684,6 @@ gtk_check_button_allocate (GtkCssGadget        *gadget,
   GtkWidget *child;
   gint check_min_width, check_nat_width;
   gint check_min_height, check_nat_height;
-  gint spacing;
   GdkRectangle check_clip;
 
   widget = gtk_css_gadget_get_owner (gadget);
@@ -707,18 +710,13 @@ gtk_check_button_allocate (GtkCssGadget        *gadget,
                                      -1,
                                      &check_min_height, &check_nat_height,
                                      NULL, NULL);
-  gtk_widget_style_get (widget,
-                        "indicator-spacing", &spacing,
-                        NULL);
 
   child = gtk_bin_get_child (GTK_BIN (button));
-  if (!child || !gtk_widget_get_visible (child))
-    spacing = 0;
 
   if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
-    child_allocation.x = allocation->x + spacing;
+    child_allocation.x = allocation->x;
   else
-    child_allocation.x = allocation->x + allocation->width - check_nat_width - spacing;
+    child_allocation.x = allocation->x + allocation->width - check_nat_width;
   child_allocation.y = allocation->y + (allocation->height - check_nat_height) / 2;
   child_allocation.width = check_nat_width;
   child_allocation.height = check_nat_height;
@@ -731,11 +729,11 @@ gtk_check_button_allocate (GtkCssGadget        *gadget,
   if (child && gtk_widget_get_visible (child))
     {
       if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
-        child_allocation.x = allocation->x + 2 * spacing + check_nat_width;
+        child_allocation.x = allocation->x + check_nat_width;
       else
         child_allocation.x = allocation->x;
       child_allocation.y = allocation->y;
-      child_allocation.width = allocation->width - check_nat_width - 2 * spacing;
+      child_allocation.width = allocation->width - check_nat_width;
       child_allocation.height = allocation->height;
 
       gtk_widget_size_allocate_with_baseline (child, &child_allocation, baseline);
index 34c610185407770a174b8d85c594c224d0bfb7c8..81aa7f2ad7d0b14c54a4d9089af8a4e4eeae3b78 100644 (file)
@@ -2140,6 +2140,14 @@ checkbutton.text-button, radiobutton.text-button {
   }
 }
 
+radiobutton radio,
+checkbutton check {
+  margin: 0 2px 0 2px;
+  &:only-child {
+    margin: 0;
+  }
+}
+
 /************
  * GtkScale *
  ************/
index e60a047bdad693b1dcf1e67a010a8e6e24b43676..4ac01b1ed4a791f830383962a9177ff30576dda3 100644 (file)
@@ -2983,6 +2983,11 @@ checkbutton.text-button, radiobutton.text-button {
     checkbutton.text-button:insensitive:backdrop, checkbutton.text-button:insensitive:active:backdrop, checkbutton.text-button:insensitive:inconsistent:backdrop, radiobutton.text-button:insensitive:backdrop, radiobutton.text-button:insensitive:active:backdrop, radiobutton.text-button:insensitive:inconsistent:backdrop {
       color: #5d6767; }
 
+checkbutton check {
+  margin: 0 2px 0 2px; }
+  checkbutton check:only-child {
+    margin: 0; }
+
 /************
  * GtkScale *
  ************/
index d9d59727a930300066c76856b39361d166230313..94fadd4c25503b852021d4af6dc4717c836d7793 100644 (file)
@@ -3145,6 +3145,11 @@ checkbutton.text-button, radiobutton.text-button {
     checkbutton.text-button:insensitive:backdrop, checkbutton.text-button:insensitive:active:backdrop, checkbutton.text-button:insensitive:inconsistent:backdrop, radiobutton.text-button:insensitive:backdrop, radiobutton.text-button:insensitive:active:backdrop, radiobutton.text-button:insensitive:inconsistent:backdrop {
       color: #c3c3c0; }
 
+checkbutton check {
+  margin: 0 2px 0 2px; }
+  checkbutton check:only-child {
+    margin: 0; }
+
 /************
  * GtkScale *
  ************/